import SwiftUI

// LookSearch
// 看一看搜索框

struct LookSearch: View {
    @Binding var searchInput: String
    
    var body: some View {
        VStack {
            Text("看一看")
                .font(.largeTitle)
                .foregroundStyle(.white)
                .padding(.bottom, 10)
            
            HStack {
                TextField("搜索", text: $searchInput)
                    // 输入设置
                    .textInputAutocapitalization(.never)
                    .autocorrectionDisabled()
                    .font(.system(size: 18))
                    // 外观设置
                    .padding(.horizontal, 20)
                    .padding(.vertical, 10)
                    .background(Color.white)
                    .cornerRadius(7.5)
                
                Button {
                    withAnimation {
                        searchInput = ""
                    }
                } label: {
                    Image(systemName: searchInput == "" ? "magnifyingglass" : "clear")
                        .resizable()
                        .scaledToFit()
                        .fontWeight(.light)
                        .foregroundColor(.white)
                        .frame(height: 35)
                }
                .disabled(searchInput == "")
            }
            .padding(.horizontal)
        }
        .padding(.vertical, 20)
        .background(Color.accentColor)
    }
}

#Preview {
    LookSearch(searchInput: .constant(""))
}
